using UnityEngine;

public class Banana : MonoBehaviour
{
	public Collider2D col;

	public int max;

	public int count;

	private void Start()
	{
		if (!CampaignGame.Instance.isPlayground)
		{
			DO.Campaign.playerHealth = Mathf.Min(DO.Campaign.playerHealth + 25f, Config.playerMaxHealth);
		}
		Invoke("Initialize", 3f);
	}

	public void Initialize()
	{
		base.gameObject.layer = 14;
		GetComponent<Rigidbody2D>().isKinematic = true;
		col.enabled = false;
	}

	private void OnTriggerEnter2D(Collider2D collision)
	{
		if (collision.gameObject.layer != 9)
		{
			return;
		}
		string text = null;
		Zombie component = collision.GetComponent<Zombie>();
		if (component.isStandable && component.isMoveable && !((double)Mathf.Abs(component.animator.transform.position.y - base.transform.position.y) > 0.4))
		{
			component.animator.GetCurrentAnimatorStateInfo(0);
			string[] array = new string[2] { "fallDownFront", "fallDownBack" };
			text = array[Random.Range(0, array.Length)];
			component.Knockback(0f, text);
			count++;
			if (count >= max)
			{
				Object.Destroy(base.gameObject);
			}
		}
	}
}
